package src;

import java.time.*;

/**
 * Created by dell on 2017/7/25.
 */
public class NewDatePackageTest {
    public static void main(String[] args) {
        Clock clock=Clock.systemUTC();
        System.out.println("当前时刻："+clock.instant());
        System.out.println(clock.millis());
        System.out.println(System.currentTimeMillis());

        Duration d=Duration.ofSeconds(6000);
        System.out.println("6000s="+d.toMinutes());
        System.out.println("6000s="+d.toHours());
        System.out.println("6000s="+d.toDays());

        Clock clock2=Clock.offset(clock,d);
        System.out.println("当前时刻加6000秒为："+clock2.instant());

        Instant instant=Instant.now();
        System.out.println(instant);

        Instant instant1=instant.plusSeconds(6000);
        System.out.println(instant1);

        Instant instant2=instant.parse("2014-02-23T10:12:35.342z");
        System.out.println(instant2);

        Instant instant3=instant2.plus(Duration.ofHours(5).plusMinutes(4));
        System.out.println(instant3);

        Instant instant4=instant3.minus(Duration.ofDays(5));
        System.out.println(instant4);

        LocalDate localDate=LocalDate.now();
        System.out.println(localDate);

        LocalTime localTime=LocalTime.now();
        localTime=localTime.of(22,33);
        System.out.println(localTime);

        localTime=LocalTime.ofSecondOfDay(5503);
        System.out.println(localTime);

        LocalDateTime localDateTime=LocalDateTime.now();
        LocalDateTime future=localDateTime.plusHours(25).plusMinutes(3);
        System.out.println("当前日期、时间的25小时3分后："+future);

        Year year=Year.now();
        System.out.println("当前年份："+year);

        year=year.plusYears(5);
        System.out.println("当前年份再过5年："+year);

        YearMonth yearMonth=year.atMonth(10);
        System.out.println("year年10月："+yearMonth);

        yearMonth=yearMonth.plusYears(5).plusMonths(3);
        System.out.println("year年10月再加5年、减3个月："+yearMonth);

        MonthDay monthDay=MonthDay.now();
        System.out.println("当前月日："+monthDay);

        MonthDay monthDay1=monthDay.with(Month.MAY).withDayOfMonth(23);
        System.out.println("5月23日为："+monthDay1);

    }
}
